<?php
namespace Home\Controller;

use Common\Controller\UserBaseController;

/**
 * 获取右侧开奖结果控制器
 */
class LastresultsController extends UserBaseController
{

    /**
     *  获取当天所有期数开奖结果
     */
    public function index()
    {
        $c_type = $_GET['lottery'];
        $g_time = $_GET['_'];
        $data   = array();

        header('Content-type:text/json');
        switch ($c_type) {

            //广西快三
            case 'GXK3': //广西快三 彩种id 7

                $condition['c_id'] = 7;
                $result            = M('lottery_results')->where($condition)->Order('id desc')->limit(20)->select();
                foreach ($result as $k => $v) {
                    $data[$k]['drawNumber'] = $v['c_no'];
                    $data[$k]['result']     = $v['lottery_result'];
                    $data[$k]['detail']     = $v['detail'];
                }
                echo json_encode($data);exit(0);
                break;

            //湖北快三
            case 'HUBK3': //湖北快三 彩种id 18

                $condition['c_id'] = 18;
                $result            = M('lottery_results')->where($condition)->Order('id desc')->limit(20)->select();
                foreach ($result as $k => $v) {
                    $data[$k]['drawNumber'] = $v['c_no'];
                    $data[$k]['result']     = $v['lottery_result'];
                    $data[$k]['detail']     = $v['detail'];
                }
                echo json_encode($data);exit(0);
                break;
            //河北快三
            case 'HEBK3': //河北快三 彩种id 19

                $condition['c_id'] = 19;
                $result            = M('lottery_results')->where($condition)->Order('id desc')->limit(20)->select();
                foreach ($result as $k => $v) {
                    $data[$k]['drawNumber'] = $v['c_no'];
                    $data[$k]['result']     = $v['lottery_result'];
                    $data[$k]['detail']     = $v['detail'];
                }
                echo json_encode($data);exit(0);
                break;
            //江苏快三
            case 'JSK3': //江苏快三 彩种id 20

                $condition['c_id'] = 20;
                $result            = M('lottery_results')->where($condition)->Order('id desc')->limit(20)->select();
                foreach ($result as $k => $v) {
                    $data[$k]['drawNumber'] = $v['c_no'];
                    $data[$k]['result']     = $v['lottery_result'];
                    $data[$k]['detail']     = $v['detail'];
                }
                echo json_encode($data);exit(0);
                break;

            default:echo json_encode($data);exit(0);
                break;

        }

    }

}
